package com.wenwu.controller;

import com.wenwu.pojo.Dept;
import com.wenwu.service.impl.DeptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: HWW
 * @Date: 2021/8/1616:27
 * @Desc:
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptServiceImpl deptService;

    //查找所有部门
    @GetMapping("/list")
    public List<Dept> findList() {
        List<Dept> list = deptService.findList();
        return list;
    }

    //根据ID查询部门信息
    @GetMapping("/findById/{id}")
    public Dept findById(@PathVariable("id") String id) {
        Dept dept = deptService.findById(id);
        return dept;
    }

    //添加部门
    @PostMapping("/add")
    public void addDept(@RequestBody Dept dept) {
        deptService.addDept(dept);

    }

    //编辑部门
    @PutMapping("/edit")
    public void edit(@RequestBody Dept dept) {
        deptService.edit(dept);
    }

    //根据ID删除部门
    @DeleteMapping("/del/{id}")
    public void deleteById(@PathVariable("id") String id) {
        deptService.deleteById(id);
    }
}
